import time

from PyQt5.QtCore import QObject, pyqtSignal, QThread

from base_api.MessageClass import Message


class SignalThread(QThread):
    signal = pyqtSignal(object)

    def __init__(self):
        super().__init__()
        self.name = ''
        # 待执行任务，被赋值为方法或函数
        self.execute_method = None

    def run(self):
        if self.execute_method is not None:
            self.execute_method()
        # 线程执行完毕
        self.signal.emit(Message(-1, ''))

    def output(self, data:object):
        self.signal.emit(Message(1, data))
